package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Coin;
import com.sk.bilibili.dto.CoinInfo;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.CoinService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 邵康
 * @date 2021/11/25 21:06
 */
@Api(tags = "硬币相关")
@CrossOrigin
@RestController
@RequestMapping("/coin")
public class CoinController {

    @Autowired
    private CoinService coinService;

    @ApiOperation("投币  投币视频id  类型 投币数量")
    @PostMapping("/add")
    public R<Void> add(@RequestBody Coin coin) {
        return coinService.add(coin);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return coinService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(@RequestBody Coin coin) {
        return coinService.update(coin);
    }

    @ApiOperation("pageSearch")
    @GetMapping("/page")
    public R<IPage<Coin>> page(@RequestParam(defaultValue = "1") Integer page,
                               @RequestParam(defaultValue = "10") Integer size) {
        return coinService.page(page, size);
    }

    @ApiOperation("获取对视频的投币信息 包含番剧  视频")
    @PostMapping("/getCoinVideo")
    public R<IPage<Coin>> getCoinVideo(@RequestBody CoinInfo coinInfo) {
        return coinService.getCoinVideo(coinInfo);
    }

}
